package com.zuoshengli.util;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;

/**
 * @Description 获取lua脚本工具
 * @Author zuoshengli
 **/
public class ScriptUtil {
    public static String getScript(String path) {
        StringBuilder sb = new StringBuilder();
        InputStream is = ScriptUtil.class.getClassLoader().getResourceAsStream(path);
        try (
                BufferedReader br = new BufferedReader(new InputStreamReader(is));
                ) {
            String line = "";
            while ((line = br.readLine()) != null) {
                sb.append(line).append(System.lineSeparator());
            }
        } catch (Exception e) {
            System.out.println(e.getStackTrace());
        }
        return sb.toString();
    }
}
